class SeatMatrix<T> {
    private int rows;
    private int cols;
    private T[][] seats;

    @SuppressWarnings("unchecked")
    public SeatMatrix(int rows, int cols) {
        this.rows = rows;
        this.cols = cols;
        this.seats = (T[][]) new Object[rows][cols];
        // 初始化座位状态
        for (int i = 0; i < rows; i++) {
            for (int j = 0; j < cols; j++) {
                seats[i][j] = null; // 默认为空，表示未售出
            }
        }
    }

    public void showSeatMatrix() {
        System.out.println("座位状态 (O=可选, X=已售):");
        for (int i = 0; i < rows; i++) {
            for (int j = 0; j < cols; j++) {
                System.out.print(seats[i][j] == null ? "O " : "X ");
            }
            System.out.println();
        }
    }

    public boolean reserveSeat(int row, int col, T value) {
        if (row < 0 || row >= rows || col < 0 || col >= cols) {
            System.out.println("无效座位号");
            return false;
        }
        if (seats[row][col] != null) {
            System.out.println("座位已售出");
            return false;
        }
        seats[row][col] = value;
        return true;
    }

    public T getSeat(int row, int col) {
        if (row < 0 || row >= rows || col < 0 || col >= cols) {
            return null;
        }
        return seats[row][col];
    }
}
